<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
$strSQL = $_SESSION[$SessionSQL];
if(strlen($strSQL) == 0){
	$intLTypeID = (int)$_data["LTypeID"];
	$arrBT = $_data["BetType"];
	if($intLTypeID == 0)$intLTypeID = 1;
		
	$strSQL = "select * from `bet_SelectGambleType` where `LType` = ".$intLTypeID;
	if(is_array($arrBT)){
		foreach($arrBT as $k => $v){
			$arrBT[$k] = (int)$v;
		}
		if(sizeof($arrBT))$strSQL .= " and BetType in (".implode(",", $arrBT).")";
	}
	
	$_SESSION[$SessionSQL] = $strSQL; 
}

$strSQLCount = str_replace("select * from", "select COUNT(*) as intTotal from", $strSQL);
if($RS = @PMA_mysql_query($strSQLCount, $$_Conn)){
	$Rows = PMA_mysql_fetch_object($RS);
	$intTotal = $Rows -> intTotal;
}

$intTotalPage = $_data["totalpage"];
$Page = (int)$_data["Page"];
$intPageNo = 15;												//一頁所要顯示的筆數
$intTotalPage = ceil($intTotal / $intPageNo);		//總共幾頁
$intPageNow = (empty($Page))? 1:$Page;		//假如目前第幾頁為空值，其值為第一頁
$intPageNow = ($intPageNow > $intTotalPage)? $intTotalPage:$intPageNow;	//目前第幾頁，假如大於總頁數，為總頁數
$intPageNow = ($intPageNow < 1)? 1:$intPageNow;	//目前第幾頁，假如小於1，為第 1 頁
if($intPageNow % 10 > 0){
	$intFirstPage = floor($intPageNow / 10)*10 + 1;
	$intLastPage = (floor($intPageNow / 10) + 1)*10;
}else{
	$intFirstPage = floor(($intPageNow - 1) / 10)*10 + 1;
	$intLastPage = (floor(($intPageNow - 1) / 10) + 1)*10;
}

$intLastPage = ($intLastPage > $intTotalPage)? $intTotalPage:$intLastPage;
?>